package io.coderyeah.ymcc.web.controller;

import io.coderyeah.ymcc.dto.RegisterDTO;
import io.coderyeah.ymcc.result.JSONResult;
import io.coderyeah.ymcc.service.IVerifyCodeService;
import io.coderyeah.ymcc.service.VerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author lqs
 * @date 2022/10/20 10:32
 */
@RestController
@RequestMapping("/verifycode")
public class verifycodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;

    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid RegisterDTO dto) {
        return verifyCodeService.sendSmsCode(dto);
    }

    /*
    生成图形验证码
    */
    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageCode(@PathVariable("imageCodeKey") String imageCodeKey) {
        return verifyCodeService.getImageCode(imageCodeKey);
    }
}
